#!/usr/bin/python
# -*- coding:utf-8 -*-
# @FileName : python_test10_2.py
# Author    : myh

# 练习 10.3：简化代码　本节前面的程序 file_reader.py 中使用了一个临
# 时变量 lines，来说明 splitlines() 的工作原理。可省略这个临
# 时变量，直接遍历 splitlines() 返回的列表：
from pathlib import Path

path = Path('python_write.txt')

contents = "I love programming.\n"
contents += "I love creating new games.\n"
contents += "I also love working with data.\n"

path.write_text(contents)
print(path.read_text())